package com.shop.controller;

import com.shop.dto.CartDto;
import com.shop.dto.CartQtyUpdate;
import com.shop.dto.CartQueryDto;
import com.shop.dto.UserInfo;
import com.shop.local.UserInfoLocal;
import com.shop.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import java.util.List;

/**
 * @author wzby
 * @Date: 2022/11/29 14:03
 */
@RestController
@RequestMapping("/api/cart")
public class CartController {
    @Autowired
    private CartService cartService;

    @PostMapping
    public Integer addCart(@RequestBody CartDto dto){
        return cartService.addCart(dto);
    }

    @GetMapping
    public List<CartDto> selectCart(CartQueryDto cartQueryDto){

        return cartService.selectCart(cartQueryDto);
    }

    @DeleteMapping
    public Long deleteCart(@RequestParam Integer memberId ,@RequestParam Integer productId){
        return cartService.deleteCart(memberId,productId);
    }

    @PatchMapping
    public Integer updateQtyCart(@RequestBody CartQtyUpdate cartQtyUpdate){
        return cartService.updateQtyCart(cartQtyUpdate);
    }
}
